// 师资信息
<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--部门数据-->
      <el-col :span="4" :xs="24">
        <DeptOptions @accessSchool="accessSchool" :type="2" />
      </el-col>
      <!--用户数据-->
      <el-col :span="20" :xs="24">
        <el-form
          :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true"
          v-show="showSearch"
          label-width="68px"
        >
          <el-form-item label="教师编号" prop="teacherCode">
            <el-input
              v-model="queryParams.teacherCode"
              placeholder="请输入教师编号"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="教师姓名" prop="name">
            <el-input
              v-model="queryParams.name"
              placeholder="请输入教师姓名"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="身份证号" prop="identNo">
            <el-input
              v-model="queryParams.identNo"
              placeholder="请输入身份证号"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="性 别" prop="sex">
            <el-select
              v-model="queryParams.sex"
              placeholder="选择全部"
              clearable
              style="width: 240px"
            >
              <el-option
                v-for="dict in dict.type.sys_user_sex"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="所属学校" prop="schoolId">
            <el-select
              v-model="queryParams.schoolId"
              placeholder="选择全部"
              clearable
              style="width: 240px"
            >
              <el-option
                v-for="item in schoolLiat"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item> -->

          <el-form-item label="资质等级" prop="className">
            <el-input
              v-model="queryParams.className"
              placeholder="请输入资质等级"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="政治面貌" prop="politicalOutlook">
            <el-select
              v-model="queryParams.politicalOutlook"
              placeholder="选择全部"
              clearable
              style="width: 240px"
            >
              <el-option
                v-for="dict in dict.type.political_outlook"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['system:user:add']"
              >新增</el-button
            >
          </el-col>

          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['system:user:remove']"
              >删除</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="handleImport"
              v-hasPermi="['system:user:import']"
              >导入</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['system:user:export']"
              >导出</el-button
            >
          </el-col>
        </el-row>

        <el-table
          v-loading="loading"
          :data="userList"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column
            label="教师编号"
            align="center"
            key="teacherCode"
            prop="teacherCode"
            width="180"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="所属学校"
            align="center"
            key="schoolName"
            prop="schoolName"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="姓名"
            align="center"
            key="name"
            prop="name"
            :show-overflow-tooltip="true"
          />

          <!-- <el-table-column
            label="年龄"
            align="center"
            key="age"
            prop="age"
            width="120"
          /> -->

          <el-table-column
            label="性别"
            align="center"
            key="sexDictText"
            prop="sexDictText"
          />

          <el-table-column
            label="户籍所在地"
            align="center"
            key="permanentResidence"
            prop="permanentResidence"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="联系方式"
            align="center"
            key="phoneNum"
            prop="phoneNum"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="操作"
            align="center"
            width="160"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit-outline"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['system:user:edit']"
                >编辑</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-share"
                @click="handleUpdate(scope.row, '详情')"
                v-hasPermi="['system:user:remove']"
                >详情</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['system:user:remove']"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>

    <!-- 添加或修改学生信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="650px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓 名" prop="name">
              <el-input
                v-model="form.name"
                placeholder="请输入教师姓名"
                maxlength="30"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系方式" prop="phoneNum">
              <el-input
                v-model="form.phoneNum"
                placeholder="联系方式"
                maxlength="11"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="性 别">
              <el-select
                v-model="form.sex"
                placeholder="请选择性别"
                :disabled="disylisr"
              >
                <el-option
                  v-for="dict in dict.type.sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="民 族">
              <el-select
                v-model="form.nation"
                placeholder="选择民族"
                clearable
                :disabled="disylisr"
              >
                <el-option
                  v-for="dict in nationLiat"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="邮 箱" prop="email">
              <el-input
                v-model="form.email"
                placeholder="请输入邮箱"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="职 称" prop="title">
              <el-input
                v-model="form.title"
                placeholder="请输入职称"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="证件类型">
              <el-select
                v-model="form.identType"
                placeholder="请选择证件类型"
                :disabled="disylisr"
              >
                <el-option
                  v-for="dict in dict.type.ident_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号" prop="identNo">
              <el-input
                v-model="form.identNo"
                placeholder="请输入身份证号"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出生年月" prop="birthDay" :disabled="disylisr">
              <el-date-picker
                v-model="form.birthDay"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择出生年月"
                style="width: 220px"       :disabled="disylisr"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="骨干级别"
              prop="backboneLevel"
          
            >
              <el-select
                v-model="form.backboneLevel"
                placeholder="请选择骨干级别"     :disabled="disylisr"
              >
                <el-option
                  v-for="dict in dict.type.backbone_level"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- <el-col :span="12">
            <el-form-item label="学 校" prop="schoolId">
              <el-select
                v-model="form.schoolId"
                placeholder="请选择所属学校"
                :disabled="disylisr"
              >
                <el-option
                  v-for="item in schoolLiat"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
          <!-- <el-col :span="12">
            <el-form-item label="班 级" prop="className">
              <el-input
                v-model="form.className"
                placeholder="请输入所属班级"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col> -->
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="教学机构" prop="schoolId">
              <el-cascader
                :options="deptOptions"
                v-model="form.schoolId"
                @change="handleChange"
                style="width: 100%"     :disabled="disylisr"
              ></el-cascader>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item
              label="政治面貌"
              prop="politicalOutlook"
            >
              <el-select
                v-model="form.politicalOutlook"
                placeholder="请选择政治面貌" :disabled="disylisr"
              >
                <el-option
                  v-for="dict in dict.type.political_outlook"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="教师编号" prop="teacherCode">
              <el-input
                v-model="form.teacherCode"
                placeholder="请输入教师编号"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="毕业学校" prop="graduatedAddress">
              <el-input
                v-model="form.graduatedAddress"
                placeholder="请输入毕业学校"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专业名称" prop="major">
              <el-input
                v-model="form.major"
                placeholder="请输入专业名称"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="学 历" prop="education">
              <el-select
                v-model="form.education"
                placeholder="请选择学历"
                :disabled="disylisr"
              >
                <el-option
                  v-for="dict in dict.type.education_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="毕业时间"
              prop="graduationTime"
         
            >
              <el-date-picker
                v-model="form.graduationTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择毕业日期"
                style="width: 225px"      :disabled="disylisr"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item
              label="参加工作时间"
              prop="workDate"
              label-width="105px"
            >
              <el-date-picker
                v-model="form.workDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择参加工作时间"
                style="width: 200px"
                :disabled="disylisr"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否心理教师" label-width="120px" prop="ifPsy">
              <el-radio-group v-model="form.ifPsy" :disabled="disylisr">
                <el-radio
                  v-for="dict in dict.type.yes_no_switch"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item
              label="是否班主任"
              label-width="120px"
              prop="ifClassTeacher"
            >
              <el-radio-group
                v-model="form.ifClassTeacher"
                :disabled="disylisr"
              >
                <el-radio
                  v-for="dict in dict.type.yes_no_switch"
                  :key="dict.value"
                  :label="dict.value"
                  >{{ dict.label }}</el-radio
                >
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="班 级" prop="classId">
              <el-select
                v-model="form.classId"
                multiple
                placeholder="请选择所属年级"      :disabled="disylisr"
              >
                <el-option
                  v-for="item in classlLiat"
                  :key="item.key"
                  :label="item.value"
                  :value="item.key"
                  style="width: 225px"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item
              label="任教学科"
              prop="discipline"
              label-width="105px"
            >
              <el-input
                v-model="form.discipline"
                placeholder="请输入任教学科"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="任教教育阶段"
              prop="educationalStage"
              label-width="105px"
            >
              <el-input
                v-model="form.educationalStage"
                placeholder="请输入任教教育阶段"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="现居住地" prop="address">
              <el-input
                v-model="form.address"
                placeholder="请输入现居住地"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="籍贯" prop="permanentResidence">
              <el-input
                v-model="form.permanentResidence"
                placeholder="请输入籍贯"
                :disabled="disylisr"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="备注">
              <el-input
                v-model="form.remark"
                type="textarea"
                placeholder="请输入内容"
                :disabled="disylisr"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm" v-if="!disylisr">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog
      :title="upload.title"
      :visible.sync="upload.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" />
            是否更新已经存在的用户数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link
            type="primary"
            :underline="false"
            style="font-size: 12px; vertical-align: baseline"
            @click="importTemplate"
            >下载模板</el-link
          >
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import DeptOptions from "@/components/DeptOptions";
import { schoolTree } from "@/api/information/index";
import {
  teacherAdd, //新增师资
  teacherPut, //修改师资
  teacherPage, //获取学生信息
  studentNations, //获取民族
  teacherDel, //删除师资
  schoolPage, //获取学校
  classPull, //获取班级
} from "@/api/information/index";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
export default {
  name: "User",
  dicts: [
    "education_type",
    "sys_user_sex",
    "sys_label_type",
    "ident_type",
    "political_outlook",
    "yes_no_switch",
    "backbone_level",
  ],
  components: { Treeselect, DeptOptions },
  data() {
    var checkIdcard = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("身份证号不能为空"));
      } else if (
        this.form.identType == "1" &&
        !/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/.test(
          value
        )
      ) {
        return callback(new Error("身份证号格式错误"));
      } else {
        callback();
      }
    };
    var classTrict = (rule, value, callback) => {
      if (this.form.ifClassTeacher == "1") {
        if (value.length == 0) {
          return callback(new Error("班级不能为空"));
        }
      } else {
        callback();
      }
    };
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: undefined,
      disylisr: false, //禁止输入
      // 日期范围
      dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {
        identType: "1",
        ifPsy: "2",
        ifClassTeacher: "2",
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/user/importData",
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 学校信息
      schoolLiat: [],
      //   班级
      classlLiat: [],
      // 名族
      nationLiat: [],
      politicsLiat: [],

      // 表单校验
      rules: {
        name: [
          { required: true, message: "姓名不能为空", trigger: "blur" },
          {
            trigger: "blur",
          },
        ],
        identNo: [{ required: true, validator: checkIdcard, trigger: "blur" }],
        classId:[{ validator:classTrict, trigger: "blur"  }],
        schoolId: [
          { required: true, message: "所属学校不能为空", trigger: "blur" },
        ],
        politicalOutlook: [
          { required: true, message: "请选择政治面貌", trigger: "blur" },
        ],
        teacherCode: [
          { required: true, message: "请输入教师编号", trigger: "blur" },
        ],
        email: [
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"],
          },
        ],
        phoneNum: [
          { required: true, message: "联系方式不能为空", trigger: "blur" },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur",
          },
        ],
      },
    };
  },
  watch: {},
  created() {
    this.getList();
    this.getNations();
    this.getschool();
    this.getDeptTree();
  },
  methods: {
    /** 查询部门下拉树结构 */
    getDeptTree() {
      schoolTree().then((response) => {
        this.deptOptions = JSON.parse(
          JSON.stringify(response.data).replace(/id/g, "value")
        );
      });
    },

    // 获取学校
    getschool() {
      schoolPage({ type: 2 }).then((res) => {
        this.schoolLiat = res.rows.map((item) => {
          return {
            value: item.id,
            label: item.name,
          };
        });
      });
    },
    /** 查询师资信息列表 */
    getList() {
      this.loading = true;
      teacherPage(this.queryParams).then((res) => {
        console.log("获取", res);
        this.userList = res.rows;
        this.total = res.total;
        this.loading = false;
      });
    },

    // 获取民族
    getNations() {
      studentNations().then((res) => {
        if (res.code == 200) {
          this.nationLiat = res.data;
        }
      });
    },

    accessSchool(data) {
      this.queryParams.pageNum = 1;
      this.queryParams.schoolId = data.id.toString();
      this.getList();
    },
    // 教学机构
    handleChange(valid) {
      if (valid) {
        this.form.schoolId = valid[valid.length - 1];
        this.schoolChange(this.form.schoolId);
      }
    },
    schoolChange(val) {
      this.classlLiat = [];
      if (val !== null || val !== "") {
        classPull(val).then((res) => {
          this.classlLiat = res.data;
          if (this.classlLiat.length == 0) {
            this.form.classId =[]
          }
        });
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;

      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        identType: "1",
        ifPsy: "2",
        ifClassTeacher: "2",
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.schoolId = undefined;

      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },

    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增教师";
      this.disylisr = false;
    },
    /** 修改按钮操作 */
    handleUpdate(row, type) {
      if (type == "详情") {
        this.open = true;
        this.title = "师资详情";
        this.disylisr = true;
      } else {
        this.open = true;
        this.title = "师资编辑";
        this.disylisr = false;
      }
      this.reset();
      this.form = row;
      this.form.sex = row.sex.toString();
      this.form.ifClassTeacher = row.ifClassTeacher.toString();
      this.form.ifPsy = row.ifPsy.toString();
      this.form.classId = row.classId.map((item) => item.toString());
      this.schoolChange(this.form.schoolId)
    },

    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          console.log("23", valid);
          if (this.form.id != undefined) {
            teacherPut(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            teacherAdd(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const userIds = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除编号为"' + userIds + '"的数据项？')
        .then(function () {
          return teacherDel(userIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/user/export",
        {
          ...this.queryParams,
        },
        `user_${new Date().getTime()}.xlsx`
      );
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "用户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download(
        "system/user/importTemplate",
        {},
        `user_template_${new Date().getTime()}.xlsx`
      );
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(
        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
          response.msg +
          "</div>",
        "导入结果",
        { dangerouslyUseHTMLString: true }
      );
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
  },
};
</script>
<style lang="scss" scoped>
.labelys {
  width: 100%;
  height: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  div:nth-child(1) {
    width: 10px;
    height: 10px;
    background-color: red;
  }
}
</style>